﻿#region

using System.Messaging;
using NsbMonitorClientService.QueueManager;
using NUnit.Framework;

#endregion

namespace NsbMonitorClientService.Tests.QueueReader
{
    
    public class can_count_messages_in_queue : with_local_test_queue
    {
        protected CountMessagesInQueue _sut;

        [SetUp]
        public void Before()
        {
            _sut = new CountMessagesInQueue();
        }
    }


    [TestFixture]
    public class can_count_messages_in_queue_when_there_are_two_messages_in_queue : can_count_messages_in_queue
    {
        [Test]
        public void execute()
        {
            Message message1 = new Message();
            Message message2 = new Message();

            LocalTestQueue1.Send(message1);
            LocalTestQueue1.Send(message2);

            int messagesCount = _sut.CountMessages(LocalTestQueue1);

            Assert.AreEqual(2, messagesCount, "messagesCount is different than expected");
        }
    }

    [TestFixture]
    public class can_count_messages_in_queue_when_there_is_one_message_in_queue : can_count_messages_in_queue
    {
        [Test]
        public void execute()
        {
            Message message1 = new Message();

            LocalTestQueue1.Send(message1);

            int messagesCount = _sut.CountMessages(LocalTestQueue1);

            Assert.AreEqual(1, messagesCount, "messagesCount is different than expected");
        }
    }

    [TestFixture]
    public class can_count_messages_in_queue_when_there_is_no_messages_in_queue : can_count_messages_in_queue
    {
        [Test]
        public void execute()
        {
            int messagesCount = _sut.CountMessages(LocalTestQueue1);

            Assert.AreEqual(0, messagesCount, "messagesCount is different than expected");
        }
    }
}